#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> PII;

#define x first
#define y second

// 化简到第一周期
pair<int, int> simplify(PII p1, PII p2)
{
    int t = min(p2.x / p1.x, p2.y / p1.y);

    return {p2.x - t * p1.x, p2.y - t * p1.y};
}

// 是否能到, target是化简后的
bool canArrive(string command, PII target)
{
    // 模拟一遍
    int x = 0, y = 0;
    if (target.x == 0 && target.y == 0)
        return true;
    for (int i = 0; i < command.size(); i++)
    {
        if (command[i] == 'U')
            y++;
        else
            x++;

        if (x == target.x && y == target.y)
        {
            return true;
        }
    }
    return false;
}

bool robot(string command, vector<vector<int>> &obstacles, int x, int y)
{
    int x0 = 0, y0 = 0;

    // 第一周期走到(x0, y0)
    for (auto a : command)
    {
        if (a == 'U')
            y0++;
        else
            x0++;
    }

    for (auto ob : obstacles)
    {
        int ox = ob[0], oy = ob[1];
        // 障碍物在终点后面
        if (ox > x || oy > y)
            continue;

        // 如果一个周期内能走到化简后的(ox, oy)
        if (canArrive(command, simplify({x0, y0}, {ox, oy})))
        {
            return false;
        }
    }

    // 看一个周期内能不能走到终点
    return canArrive(command, simplify({x0, y0}, {x, y}));
}

int main()
{
    string s;
    cin >> s;


    int n, x0, y0;
    cin >> n;
    vector<vector<int>> obs;

    while (n--)
    {
        vector<int> ob(2);
        cin >> ob[0] >> ob[1];
        obs.push_back(ob);
    }

    cin >> x0 >> y0;
    cout << (robot(s, obs, x0, y0) ? "true" : "false") << endl;
    return 0;
}

/*
URR
1
2 2
3 2
*/
